/****************************************Copyright (c)****************************************************
 
**--------------File Info---------------------------------------------------------------------------------
** File name:                sinewave.h
** Last modified Date:       2024.08.04
** Last Version:             Ver:1.0
** Descriptions:             使用DMA和定时器生成正弦波。通过预先定义的正弦波数据数组和硬件资源的配置，可以
**                           实现对定时器PWM输出的高效控制，从而输出连续的正弦波形。
**                        
**--------------------------------------------------------------------------------------------------------
** Created by:               adm
** Created date:             2024.08.04
** Version:                  Ver:1.0
** Descriptions:             使用DMA和定时器生成正弦波。通过预先定义的正弦波数据数组和硬件资源的配置，可以
**                           实现对定时器PWM输出的高效控制，从而输出连续的正弦波形。
**--------------------------------------------------------------------------------------------------------*/
/*
Copyright (c) [2024]     [BA6IV  ]   [SINEWAVE] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan
PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#ifndef __SINEWAVE_H
#define __SINEWAVE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "at32f415.h"
#include "at32f415_wk_config.h"


#define PWM_CONSTANT            585937          //PWM常数 = 150000000 / 256
#define SPWM_TMR                TMR1

/* var extern zone */
extern uint16_t sin_data[256];


/* Function zone */
void sin_data_init(uint32_t Period_value);
void sin_freq_set(uint32_t freq);
void sin_data_scale_set(uint8_t scale);
void Sinewave_Init(void);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif
